# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=wfuzz
pkgver=1155.1b695ee
pkgrel=10
groups=('blackarch' 'blackarch-fuzzer' 'blackarch-webapp')
pkgdesc='Utility to bruteforce web applications to find their not linked resources.'
url='https://github.com/xmendez/wfuzz'
arch=('any')
license=('GPL2')
depends=('python' 'python-lxml' 'python-pycurl' 'python-chardet' 'python-six'
         'python-future' 'python-wxpython' 'python-pyparsing')
makedepends=('git')
source=('git+https://github.com/xmendez/wfuzz.git')
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  _tools='wfencode wfuzz wfpayload wxfuzz'

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf LICENSE README.md setup.py docs *.md tests *.bat Dockerfile build \
    Makefile MANIFEST.in requirements.txt "$pkgname.egg-info"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  for t in $_tools; do
    if [ "$t" = "wfuzz" ]; then
      cat > "$pkgdir/usr/bin/$t" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python src/$t-cli.py "\$@"
EOF
    else
      cat > "$pkgdir/usr/bin/$t" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python src/$t.py "\$@"
EOF
    fi
    chmod +x "$pkgdir/usr/bin/$t"
  done

  rm -rf "$pkgdir/usr/share/wfuzz/src/wfuzz/__pycache__/"
}

